#include "mainwindow.h"

#include <QApplication>
#include <QFile>
#include <stdio.h>

void printError(const char* msg)
{
    QFile file;
    file.open(stderr, QIODevice::WriteOnly);
    file.write(msg, qstrlen(msg));        // write to stderr
            file.close();
}

int writeDemo()
{
    FILE *pf = fopen("test.txt", "wb");
    if(pf == nullptr)
        return 0;
    QFile file;
    file.open(pf, QIODevice::WriteOnly); //1
    //      file.open(pf, QIODevice::WriteOnly, QFileDevice::AutoCloseHandle); //2
    file.write("hello");
    file.close();
    fwrite("world", strlen("world"), 1, pf); // 这一个还能够写入成功
    return 0;
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
        MainWindow w;
        w.show();

//    printError("HHHH");



    return a.exec();
}
